<!-- 回复评论组件 -->
<template>
  <div>
    <!-- 顶部导航 -->
    <van-nav-bar :title="comment.reply_count ? comment.reply_count +'条回复' : '暂无回复'">
      <van-icon slot="left" name="cross" @click="$emit('closepopup')" />
    </van-nav-bar>

    <!-- 滚动区域 -->
    <div class="score">
      <!-- 当前评论 -->
      <commentItem :comment="comment"></commentItem>

      <van-cell title="全部回复" />

      <articleComment type="c" :source="comment.com_id + ''" :list="list"></articleComment>
    </div>

    <!-- 底部区域 -->
    <div class="post-warp">
      <van-button round @click="replyShow = true">评论</van-button>
    </div>

    <!-- 发布回复弹出层 -->
    <van-popup v-model="replyShow" position="bottom">
      <articlePost @onPostSuccess="onPostSuccess" :target="comment.com_id" :artId="$route.params.articleId">
      </articlePost>
    </van-popup>
  </div>
</template>

<script>
// 导入文章评论组件
import commentItem from '@/components/article-item/comment-item.vue'
// 导入评论列表
import articleComment from './article-common.vue'
// 导入发布评论组件
import articlePost from './article-post.vue'
export default {
  props: {
    // 父组件评论数据
    comment: {
      type: Object,
      require: true
    }
  },
  data () {
    return {
      list: [],
      // 发布回复弹出层显示
      replyShow: false
    }
  },
  methods: {
    // 发布成功
    onPostSuccess (e) {
      this.replyShow = false
      this.list.unshift(e)
      this.comment.reply_count++
    }
  },
  computed: {},
  watch: {},
  filters: {},
  components: {
    commentItem,
    articleComment,
    articlePost
  },
  created () { },
  mounted () { }
}
</script>

<style scoped lang='less'>
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1989fa;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.score {
  position: fixed;
  width: 100%;
  top: 92px;
  bottom: 102px;
  overflow-y: scroll;
}
</style>
